package com.umgsai.thread.thread62;

import java.sql.Connection;
import java.sql.DriverManager;

public enum MyObject {
	connectionFactory;
	private Connection connection;
	private MyObject(){
		try {
			System.out.println("创建MyObject对象");
			String url = "jdbc:mysql://127.0.0.1:3306/test";
			String user = "root"; 
	        String password = "";
	        String driver = "com.mysql.jdbc.Driver";
	        Class.forName(driver);
	        connection = DriverManager.getConnection(url, user, password);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public Connection getConnection() {
		return connection;
	}
}
